package com.ty.xiaoyu.util;

import javax.servlet.http.HttpServletRequest;

public class URLUtil {

    /**
     * 获取当前项目的URL（http://39.97.236.46:18081/xiaoyu）
     * @param request 前端请求
     * @return URL
     */
    public static String getURL(HttpServletRequest request) {
        String serverName = request.getServerName();
        int serverPort = request.getServerPort();
        String contextPath = request.getContextPath();
        return "http://" + serverName + ":" + serverPort + contextPath;
    }
}
